package com.government.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.government.common.core.domain.entity.SysUser;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.government.system.mapper.ImMailMapper;
import com.government.system.domain.ImMail;
import com.government.system.service.IImMailService;

import static com.government.common.utils.PageUtils.startPage;
import static com.government.common.utils.SecurityUtils.getLoginUser;

/**
 * 站内信Service业务层处理
 *
 * @author system
 * @date 2023-11-10
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ImMailServiceImpl implements IImMailService {

    @Autowired
    private ImMailMapper imMailMapper;

    @Override
    public List<ImMail> getUserIImMailList() {
        SysUser user = getLoginUser().getUser();

        startPage();
        List<ImMail> imMailList = imMailMapper.selectList(Wrappers.<ImMail>lambdaQuery()
                .eq(ImMail::getUserId, user.getUserId()).orderByDesc(ImMail::getCreateTime));

        imMailMapper.read(user.getUserId());
        return imMailList;
    }

}
